package com.neutech.shop.mapper.impl;

import com.neutech.shop.entity.User;
import com.neutech.shop.mapper.UserMapper;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Neuedu-远哥
 * @version 1.0
 * @date 2021/9/22 9:38
 */
@Repository
public class UserMapperImpl extends SqlSessionDaoSupport implements UserMapper {

    @Resource
    @Override
    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        super.setSqlSessionFactory(sqlSessionFactory);
    }
    @Override
    public List<User> selectAll() {
        return getSqlSession().getMapper(UserMapper.class).selectAll();
    }

    @Override
    public void insert(User user) {
        getSqlSession().getMapper(UserMapper.class).insert(user);
    }

    @Override
    public void delete(Long id) {
        getSqlSession().getMapper(UserMapper.class).delete(id);
    }

    @Override
    public User selectById(Long id) {
        return getSqlSession().getMapper(UserMapper.class).selectById(id);
    }

    @Override
    public void update(User user) {
        getSqlSession().getMapper(UserMapper.class).update(user);
    }

    @Override
    public void updateStatus(User user) {
        getSqlSession().getMapper(UserMapper.class).updateStatus(user);
    }

    @Override
    public User findByUsername(String username) {
        return getSqlSession().getMapper(UserMapper.class).findByUsername(username);
    }
}
